package com.bos.web.action;

import com.bos.domian.base.Order;
import com.bos.service.OrderService;
import com.bos.web.BaseAction;
import com.opensymphony.xwork2.ActionContext;
import org.apache.struts2.convention.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.Map;

/**
 * @author misterWei
 * @create 2018年11月26号:11点38分
 * @mailbox mynameisweiyan@gmail.com
 */
@ParentPackage("json-default")
@Actions
@Namespace("/")
@Controller
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)//多例的
public class OrderAction extends BaseAction<Order> {
    @Autowired
    private OrderService orderService;
    @Action(value = "order_findByOrderNum",results = {@Result(type = "json")})
    public String findByOrderNum (){
      Order order  = orderService.findByOrderNum(model.getOrderNum());
        Map<String,Object> ordeResult = new HashMap<>();
     if (order==null){
         ordeResult.put("success",false);
     }else {
         ordeResult.put("success",true);
         ordeResult.put("orderData",order);
     }
        ActionContext.getContext().getValueStack().push(ordeResult);
        return SUCCESS;
    }
}
